#tsinghua mirror
https://mirrors.tuna.tsinghua.edu.cn/help/fedora/

# sudo不输入密码
sudo echo "super ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
#普通用户不用输入密码
sudo groupadd sudo
sudo groupadd admin
sudo usermod -G sudo super
sudo usermod -G admin super

#chromium
#https://www.chrome64bit.com/index.php/google-chrome-64-bit-for-linux
yum install -y chromium chromium-l10n chromium-shell chromium-driver chromium-widevine

#好用的浏览器
yum install -y qupzilla midori opera firefox

#kate: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
sudo strip --remove-section=.note.ABI-tag /usr/lib64/libQt5Core.so.5

#win10-virtualBox-centOS8-解决增强功能安装失败
sudo dnf update kernel -y
sudo dnf install -y kernel kernel-headers kernel-devel gcc make
sudo dnf install -y dkms elfutils-libelf-devel
sudo dnf install -y RemoteBox fence-agents-vbox libvirt-daemon-driver-vbox libvirt-daemon-vbox

#cinnamon
dnf install -y cinnamon-desktop deepin-desktop lightdm

#安装图形界面
dnf install -y xfce4 xfce4-terminal
#配置.bashrc
export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1

#windows命令运行
vcxsrv -ac

#启动图形界面，需配XServer使用
startxfce4

# release lock file
find /var/lib/rpm/ -name '*.lock' -delete

#自定义别名
grep "alias cls='clear'" ~/.bashrc > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.bashrc <<-EOF
alias cls='clear'
alias yum='sudo yum'
alias yumi='yum install -y'
alias yumr='yum remove -y'
alias yums='yum search'
alias dnf='sudo dnf'
alias dnfi='dnf install -y'
alias dnfr='dnf remove -y'
alias dnfs='dnf search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip --trusted-host mirrors.aliyun.com'
alias pip3='sudo -H pip3 --trusted-host mirrors.aliyun.com'
alias vim='sudo vim'
alias nvim='sudo nvim'
alias vi='vim'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=nvim
export LANG=zh_CN.UTF-8
EOF
source ~/.bashrc
fi

sudo yum install -y yum-fastestmirror

sudo yum install -y wget curl git tree

sudo yum install -y epel-release

#常用开发工具
sudo yum install -y ntp net-tools sysstat
sudo yum install -y chromium
sudo yum install -y tree vim dos2unix
sudo yum install -y terminator
sudo yum install -y kernel-devel
sudo yum install -y gcc cpp gcc-c++ gd-devel glibc-doc
sudo yum install -y ncurses ncurses-devel
sudo yum install -y zlib zlib-devel
sudo yum install -y freetype-devel freetype-demos freetype-utils
sudo yum install -y openssl openssl-devel
sudo yum install -y openssh-server
sudo yum install -y bzip2-devel sqlite-devel
sudo yum install -y python-devel python36-devel
#sudo yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
sudo yum install -y java-latest-openjdk
sudo yum install -y manpages-posix-dev
sudo yum install -y man-pages man-db man2html help2man most
sudo yum install -y rust cargo golang
sudo yum install -y kate gedit

sudo yum install -y nodejs npm
sudo npm config set registry https://registry.npm.taobao.org
sudo npm i -g npm
sudo npm i -g cnpm --registry https://registry.npm.taobao.org
sudo npm i -g yarn --registry https://registry.npm.taobao.org
sudo npm i -g tldr
sudo npm i -g cheat
mkdir -p ~/.config/cheat && cheat --init > ~/.config/cheat/conf.yml

yum install -y python2 python2-pip python2-setuptools
yum install -y python3 python3-pip python3-setuptools

[ -e ~/.pip ] || sudo mkdir ~/.pip
[ -e ~/.pip/pip.conf ] || sudo touch ~/.pip/pip.conf
sudo chmod a+w ~/.pip/pip.conf
cat > ~/.pip/pip.conf <<-EOF
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
EOF
pip install --user --upgrade pip --trusted-host mirrors.aliyun.com

pip install --user --trusted-host mirrors.aliyun.com flake8 jedi isort yapf pygments ptpython

#zsh
sudo pacman -S bat zsh zsh-autosuggestions autojump zsh-syntax-highlighting
#oh my zsh
sudo git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
sudo cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
#手工安装autojump
cd ~/.oh-my-zsh/custom/plugins
sudo git clone git://github.com/joelthelion/autojump.git
cd autojump
python3 install.py
#zsh plugins
git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/paulirish/git-open.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/git-open
#~/.zshrc
sed -i 's/plugins=(git)/plugins=(git git-open autojump zsh-autosuggestions zsh-syntax-highlighting)/g' ~/.zshrc
source ~/.zshrc

chsh -s /usr/bin/zsh

#.zshrc config
grep "alias cls='clear'" ~/.zshrc > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.zshrc <<-EOF
alias cls='clear'
alias yum='sudo yum'
alias yumi='yum install -y'
alias yumr='yum remove -y'
alias yums='yum search'
alias dnf='sudo dnf'
alias dnfi='dnf install -y'
alias dnfr='dnf remove -y'
alias dnfs='dnf search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip --trusted-host mirrors.aliyun.com'
alias pip3='sudo -H pip3 --trusted-host mirrors.aliyun.com'
alias vim='sudo vim'
alias vi='vim'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
EOF
source ~/.zshrc
fi

#fish & oh my fish
sudo yum install -y fish
sudo git clone https://github.com/oh-my-fish/oh-my-fish
cd oh-my-fish
bin/install --offline

#fish config
[ -e touch ~/.config/fish/config.fish ] || touch ~/.config/
grep "alias cls='clear'" ~/.config/fish/config.fish > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.config/fish/config.fish <<-EOF
alias cls='clear'
alias yum='sudo yum'
alias yumi='yum install -y'
alias yumr='yum remove -y'
alias yums='yum search'
alias dnf='sudo dnf'
alias dnfi='dnf install -y'
alias dnfr='dnf remove -y'
alias dnfs='dnf search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip --trusted-host mirrors.aliyun.com'
alias pip3='sudo -H pip3 --trusted-host mirrors.aliyun.com'
alias vim='sudo vim'
alias vi='vim'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
EOF
source ~/.config/fish/config.fish
fi

#space-vim
sudo curl -sLf https://spacevim.org/cn/install.sh | bash